<?php

/**
 * This is the model class for table "sys_serial_products_request".
 *
 * The followings are the available columns in table 'sys_serial_products_request':
 * @property string $serial_products_request_id
 * @property string $serial_products_request_network_id
 * @property string $serial_products_request_products_category_id
 * @property string $serial_products_request_datetime
 * @property string $serial_products_request_is_accepted
 */
class sys_serial_products_request extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @return sys_serial_products_request the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'sys_serial_products_request';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('serial_products_request_network_id', 'length', 'max' => 20),
            array('serial_products_request_products_category_id', 'length', 'max' => 10),
            array('serial_products_request_is_accepted', 'length', 'max' => 1),
            array('serial_products_request_datetime', 'safe'),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('serial_products_request_id, serial_products_request_network_id, serial_products_request_products_category_id, serial_products_request_datetime, serial_products_request_is_accepted', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
            'rel_serial_products_request_to_network' => array(self::BELONGS_TO, 'sys_network', 'serial_products_request_network_id'),
            'rel_serial_products_request_to_products_category' => array(self::BELONGS_TO, 'ecom_products_category', 'serial_products_request_products_category_id'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'serial_products_request_id' => 'Serial Products Request',
            'serial_products_request_network_id' => 'Serial Products Request Network',
            'serial_products_request_products_category_id' => 'Serial Products Request Products Category',
            'serial_products_request_datetime' => 'Serial Products Request Datetime',
            'serial_products_request_is_accepted' => 'Serial Products Request Is Accepted',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('serial_products_request_id', $this->serial_products_request_id, true);
        $criteria->compare('serial_products_request_network_id', $this->serial_products_request_network_id, true);
        $criteria->compare('serial_products_request_products_category_id', $this->serial_products_request_products_category_id, true);
        $criteria->compare('serial_products_request_datetime', $this->serial_products_request_datetime, true);
        $criteria->compare('serial_products_request_is_accepted', $this->serial_products_request_is_accepted, true);

        return new CActiveDataProvider($this, array(
                    'criteria' => $criteria,
                ));
    }

}